home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / util / shell / axuucp_0_1.lha / axsh / rexx / rn-update.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-03-22  |  2.5 KB  |  91 lines

  1. /****** axuucp/rn-update *****************************************************
  2. *
  3. *   NAME
  4. *    rn-update - Update Newsgroup's .lowest & .next files
  5. *
  6. *   SYNOPSIS
  7. *    rx rn-update.rexx
  8. *
  9. *   DESCRIPTION
  10. *    For each group listed in /usr/spool/news/NewsGroups the .lowest and
  11. *    .next file will be updated.  This is useful when using external
  12. *    spooler for AXsh news such as "tin -Sc".
  13. *
  14. *   AUTHOR
  15. *    Tobias Ferber <tf@ganymed.hall.sub.org>
  16. *
  17. ******************************************************************************
  18. *
  19. */
  20.  
  21. axnews     = axconfig("news")
  22. newsgroups = axconfig("newsgroupfile")
  23. tempfile   = "t:rn-update." || pragma('Id')
  24.  
  25. call open('fp',newsgroups)
  26.  
  27. do until eof('fp')
  28.   gname= word(readln('fp'),1)
  29.   if words(gname) > 0 then do
  30.     gdir= axnews || translate(gname,'/','.')
  31.     address command 'list files dir' gdir 'lformat "%8n" pat "~(.#?)" >' tempfile
  32.     address command 'rx "setclip(''a'',''`wc -w <' tempfile'`'')"'
  33.     a= strip(getclip('a'),'b',d2c(9)); /*say a 'artile(s) in' gname*/
  34.     if a>0 then do
  35.       address command 'sort from' tempfile 'to' tempfile
  36.       address command 'eval 0+`head -1' tempfile '` >' gdir'/.lowest'
  37.       address command 'eval 1+`tail -1' tempfile '` >' gdir'/.next'
  38.       end
  39.     end
  40.   end
  41.  
  42. call close('fp')
  43. address command 'delete quiet' tempfile
  44. exit
  45.  
  46. /*@<axconfig>*/
  47.  
  48. /* get an AXsh configuration value */
  49.  
  50. axconfig: procedure
  51.   tempfile = "T:axconfig." || pragma('Id')
  52.   rc_index  = "AXsh:rexx/rc.index"
  53.   var_val=""; var_file=""; var_defval="";
  54.  
  55.   parse upper arg var_name
  56.   if left(var_name,1) ~= '%' then var_name = '%'var_name
  57.   if right(var_name,1) ~= ':' then var_name = var_name':'
  58.  
  59.   if open('idx',rc_index,'Read') then do
  60.     do until (eof('idx') | (var_file~=''))
  61.       str= translate(readln('idx'),' ',d2c(9))
  62.       if words(str) > 0 then do
  63.         parse var str vname ' ' fname '"' defval '"'
  64.         if upper(vname) = var_name then do
  65.           var_file= strip(fname,'B',' 'd2c(9))
  66.           var_defval= defval
  67.           end
  68.         end
  69.       end
  70.     call close('idx')
  71.     end
  72.   else say 'Could not read "'rc_index'"'
  73.  
  74.   if words(var_file) > 0 then do
  75.     if open('rc',var_file,'Read') then do
  76.       do until (eof('rc') | (var_val~=''))
  77.         str= translate(readln('rc'),' ',d2c(9))
  78.         if upper(word(str,1)) = var_name then var_val = strip(readln('rc'),'B',' 'd2c(9))
  79.         end
  80.       call close('rc')
  81.       end
  82.     else say 'Could not examine "'var_file'" for' var_name
  83.     end
  84.   else do
  85.     if words(var_defval) > 0 then var_val= var_defval
  86.     else say 'No such config variable:' var_name
  87.     end
  88.  
  89.   return var_val
  90.  
  91.